home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / mail / pine3.96.tar.gz / pine3.96.tar / pine3.96 / contrib / utils / mailtrfc.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1992-06-01  |  6KB  |  131 lines

  1. #!/bin/sh
  2. #
  3. #            T H E    P I N E    M A I L   S Y S T E M
  4. #
  5. #   Laurence Lundblade and Mike Seibel
  6. #   Networks and Distributed Computing
  7. #   Computing and Communications
  8. #   University of Washington
  9. #   Administration Building, AG-44
  10. #   Seattle, Washington, 98195, USA
  11. #   Internet: lgl@CAC.Washington.EDU
  12. #             mikes@CAC.Washington.EDU
  13. #
  14. #   Please address all bugs and comments to "pine-bugs@cac.washington.edu"
  15. #      
  16. #   Copyright 1991, 1992  University of Washington
  17. #
  18. #    Permission to use, copy, modify, and distribute this software and its
  19. #   documentation for any purpose and without fee is hereby granted, provided
  20. #   that the above copyright notice appears in all copies and that both the
  21. #   above copyright notice and this permission notice appear in supporting
  22. #   documentation, and that the name of the University of Washington not be
  23. #   used in advertising or publicity pertaining to distribution of the software
  24. #   without specific, written prior permission.  This software is made
  25. #   available "as is", and
  26. #   THE UNIVERSITY OF WASHINGTON DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,
  27. #   WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION ALL IMPLIED
  28. #   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND IN
  29. #   NO EVENT SHALL THE UNIVERSITY OF WASHINGTON BE LIABLE FOR ANY SPECIAL,
  30. #   INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  31. #   LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT
  32. #   (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF OR IN CONNECTION
  33. #   WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  34. #  
  35. #
  36. #   Pine is in part based on The Elm Mail System:
  37. #    ***********************************************************************
  38. #    *  The Elm Mail System  -  $Revision: 2.13 $   $State: Exp $          *
  39. #    *                                                                     *
  40. #    *             Copyright (c) 1986, 1987 Dave Taylor              *
  41. #    *             Copyright (c) 1988, 1989 USENET Community Trust   *
  42. #    ***********************************************************************
  43. #
  44.  
  45.  
  46. # mailtrfc.sh -- A shell script to analyze the mail traffic as logged in
  47. # /usr/spool/mqueue/syslog*. This currently as the University of Washington
  48. # domains wired in and needs to be made more general. Also, lots more
  49. # formats of message ID's could be added.
  50. #
  51.  
  52.  
  53.  
  54. org=`awk '/^domain/ {print $2}' < /etc/resolv.conf`
  55. domain=`echo $org | sed -e 's/^[^.]*\.//'`
  56. host=`hostname`".$org"
  57.  
  58. echo "Domain: $domain"
  59. echo "Organization: $org"
  60. echo "Hostname: $host"
  61.  
  62. sed -n -e '/message-id/s/^.*</</p' |
  63. awk 'BEGIN {mailers[0] =  "Other";
  64.             mailers[1] =  "Pine";
  65.             mailers[2] =  "MailManager";
  66.             mailers[3] =  "sendmail";
  67.             mailers[4] =  "BITNET";
  68.             mailers[5] =  "? news ?";
  69.             mailers[6] =  "Sprint";
  70.             mailers[7] =  "X.400";
  71.             mailers[8] =  "Mac MS";
  72.             mailers[9] =  "MMDF";
  73.             mailers[10] = "Andrew";
  74.             mailers[11] = "Columbia MM";
  75.             mailers[12] = "Unknown #1";
  76.             mailers[13] = "EasyMail";
  77.             mailers[14] = "CompuServe";
  78.             mailers[15] = "smail";
  79.             mailers[16] = "MCI Mail";
  80.             mailers[17] = "VAX MAIL(?)";
  81.             mailers[18] = "Gator Mail (?)";
  82.             mailers[19] =  "TOTAL";
  83.             max = 19;}
  84.                                       {mailer = 0;}
  85.      /^<Pine/                         {mailer = 1;}
  86.      /^<MailManager/                  {mailer = 2;}
  87.      /^<[12]?[90]?9[0-9]1?[0-9][1-3]?[0-9]+\.[AaBb][AaBb][0-9]+@/ {mailer = 3;}
  88.      /^<[0-9A-Z]+@/                   {mailer = 4;}
  89.      /^<199[0-9][A-Za-z]..[0-9]*\./   {mailer = 5;}
  90.      /@sprint.com/                    {mailer = 6;}
  91.      /\/[A-Z]*=.*\/[A-Z]*=.*/         {mailer = 7;}
  92.      /^<MacMS\.[0-9]+\.[0-9]+\.[a-z]+@/ {mailer = 8;}
  93.      /^<MAILQUEUE-[0-9]+\.[0-9]+/           {mailer = 9;}
  94.      /^<.[d-l][A-Z0-9a-z=_]+00[A-Za-z0-9_=]+@/ {mailer = 10;}
  95.      /^<CMM\.[0-9]+\.[0-9]+\.[0-9]+/    {mailer = 11 ;}
  96.      /^<9[0-9][JFMASOND][aepuco][nbrylgptvc][0-9][0-9]?\.[0-9]+[a-z]+\./ {mailer = 12;}
  97.      /^<EasyMail\.[0-9]+/               {mailer = 13;}
  98.      /@CompuServe.COM/                  {mailer = 14;}
  99.      /^<m[A-Za-z0-9].....-[0-9A-Za-z].....C@/       {mailer = 15;}
  100.      /@mcimail.com/                     {mailer = 16;}
  101.      /^<9[0-9][01][0-9][0-3][0-9][0-2][0-9][0-5][0-9][0-5][0-9].[0-9a-z]*@/ {mailer = 17;}
  102.      /^<0[0-9][0-9]+\.[0-9][0-9][0-9][0-9]+\.[0-9][0-9]+@/ {mailer=18;}
  103.  
  104.     
  105.  
  106.      '"/$domain>/"'              {campus[mailer]++; campus[max]++}
  107.      '"/$org>/"'                 {u[mailer]++; u[max]++}
  108.      '"/$host>/"'                {milton[mailer]++; milton[max]++}
  109.                                  {total[mailer]++; total[max]++}
  110.                                  {if(mailer == 0) printf("-->%s\n",$0)}
  111.      END {
  112.             for(m = 0; m <= max; m++)  {
  113.                 printf("%-10.10s", mailers[m]);
  114.                 printf(" %11d %11d %11d %11d %11d (%3d%%)\n",  milton[m], u[m] - milton[m], campus[m] -u[m], total[m] - campus[m], total[m], (total[m]*100)/total[max]);
  115.             }
  116.             printf(" ----           (%3d%%)      (%3d%%)      (%3d%%)      (%3d%%)\n", (milton[max]*100)/total[max], ((u[max] - milton[max])*100)/total[max], ((campus[max] - u[max])*100)/total[max], ((total[max] - campus[max])*100)/total[max], (u[max]*100)/total[max]);
  117.  
  118.         }' > /tmp/syslogx.$$
  119.  
  120.  
  121. echo $host $org $domain | \
  122.   awk '{printf("     %.17s %.11s %.11s  Off Campus        Total\n", $1, $2, $3)}'
  123. egrep -v 'TOTAL|----|^-->' /tmp/syslogx.$$ | sort +0.60rn 
  124. egrep  'TOTAL|----' /tmp/syslogx.$$
  125. grep  '^-->' /tmp/syslogx.$$ | sed -e 's/-->//' > other-traffic
  126. rm -f /tmp/syslogx.$$
  127.  
  128.  
  129.